package com.apptravel.dao;

import com.apptravel.entity.Admin;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Component;

@Component("adminDao")
public class AdminDAOImpl extends MybatisDao implements AdminDAO {

    public AdminDAOImpl() {
        super();
    }

    public int deleteById(Integer id) {
        Admin _key = new Admin();
        _key.setId(id);
        int rows = getSqlSession().delete("admin.deleteById", _key);
        return rows;
    }

    public void insert(Admin record) {
        getSqlSession().insert("admin.insert", record);
    }



    public Admin selectById(Integer id) {
        Admin _key = new Admin();
        _key.setId(id);
        Admin record = (Admin) getSqlSession().selectOne("admin.selectById", _key);
        return record;
    }

    public Admin selectByName(String userName) {
        Admin _key = new Admin();
        _key.setUsername(userName);
        Admin record = (Admin) getSqlSession().selectOne("admin.selectByName", _key);
        return record;
    }


    public int updateById(Admin record) {
        int rows = getSqlSession().update("admin.updateById", record);
        return rows;
    }
}